/*

 * Copyright (C) 2021 Huawei Device Co., Ltd.

 * Licensed under the Apache License, Version 2.0 (the "License");

 * you may not use this file except in compliance with the License.

 * You may obtain a copy of the License at

 *

 *     http://www.apache.org/licenses/LICENSE-2.0

 *

 * Unless required by applicable law or agreed to in writing, software

 * distributed under the License is distributed on an "AS IS" BASIS,

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 * See the License for the specific language governing permissions and

 * limitations under the License.

 */
package com.headerfooter.songhang.library.component;

import ohos.agp.components.Component;

/**
 * 回收Item类
 */
public class RecyclerItem {
    public RecyclerItem() {
    }

    SpanLayoutManager.Span span;

    int index = 0;
    int marginLeft = 0;
    int marginTop = 0;
    int marginRight = 0;
    int marginBottom = 0;
    int positionX = 0;
    int positionY = 0;
    int width = 0;
    int height = 0;

    Component child;

    /**
     * 获取左边位置
     *
     * @return int
     */
    public int getLeft() {
        return positionX;
    }

    /**
     * 获取顶部位置
     *
     * @return int
     */
    public int getTop() {
        return positionY;
    }

    /**
     * 获取右边位置
     *
     * @return int
     */
    public int getRight() {
        return positionX + marginLeft + marginRight + width;
    }

    /**
     * 获取底部位置
     *
     * @return int
     */
    public int getBottom() {
        return positionY + marginTop + marginBottom + height;
    }

    /**
     * 获取横向间隔
     *
     * @return int
     */
    public int getHSpace() {
        return marginLeft + marginRight + width;
    }

    /**
     * 获取垂直间隔
     *
     * @return int
     */
    public int getVSpace() {
        return marginTop + marginBottom + height;
    }

    /**
     * 销毁组件
     *
     * @return Component
     */
    public Component recycleComponent() {
        Component temp = child;
        child = null;
        return temp;
    }

    @Override
    public String toString() {
        return "Layout{" +
                "index=" + index +
                ", positionX=" + positionX +
                ", positionY=" + positionY +
                ", width=" + width +
                ", height=" + height +
                '}';
    }

    /**
     * 获取左边间距
     *
     * @return int
     */
    public int getMarginLeft() {
        return marginLeft;
    }

    /**
     * 设置左边间距
     *
     * @param marginLeft 间距值
     */
    public void setMarginLeft(int marginLeft) {
        this.marginLeft = marginLeft;
    }

    /**
     * 获取顶部间距
     *
     * @return int
     */
    public int getMarginTop() {
        return marginTop;
    }

    /**
     * 设置顶部间距
     *
     * @param marginTop 间距值
     */
    public void setMarginTop(int marginTop) {
        this.marginTop = marginTop;
    }

    /**
     * 获取右边间距
     *
     * @return int
     */
    public int getMarginRight() {
        return marginRight;
    }

    /**
     * 设置右边间距
     *
     * @param marginRight 间距值
     */
    public void setMarginRight(int marginRight) {
        this.marginRight = marginRight;
    }

    /**
     * 获取底部间距
     *
     * @return int
     */
    public int getMarginBottom() {
        return marginBottom;
    }

    /**
     * 设置底部间距
     *
     * @param marginBottom 间距值
     */
    public void setMarginBottom(int marginBottom) {
        this.marginBottom = marginBottom;
    }

    /**
     * 获取横坐标位置
     *
     * @return int
     */
    public int getPositionX() {
        return positionX;
    }

    /**
     * 设置横坐标位置
     *
     * @param positionX 坐标值
     */
    public void setPositionX(int positionX) {
        this.positionX = positionX;
    }

    /**
     * 获取纵坐标位置
     *
     * @return int
     */
    public int getPositionY() {
        return positionY;
    }

    /**
     * 设置纵坐标位置
     *
     * @param positionY 坐标值
     */
    public void setPositionY(int positionY) {
        this.positionY = positionY;
    }

    /**
     * 获取宽度
     *
     * @return int
     */
    public int getWidth() {
        return width;
    }

    /**
     * 设置宽度
     *
     * @param width 宽度
     */
    public void setWidth(int width) {
        this.width = width;
    }

    /**
     * 获取高度
     *
     * @return int
     */
    public int getHeight() {
        return height;
    }

    /**
     * 设置高度
     *
     * @param height 高度
     */
    public void setHeight(int height) {
        this.height = height;
    }
}
